package leetCode.secondWeek;

public class Code_26 {
  public int removeDuplicates(int[] nums) {
    if (nums.length == 0) {
      return 0;
    }
    int tmp = nums[0];
    for (int i = 1; i < nums.length; i++) {
      if (nums[i] < tmp) {
        return i;
      }
      if (nums[i] == tmp) {
        for (int j = i + 1; j < nums.length; j++) {
          nums[j - 1] = nums[j];
        }
        nums[nums.length - 1] = Integer.MIN_VALUE;
        i--;
        continue;
      }

      if (nums[i] != tmp && nums[i] > tmp) {
        tmp = nums[i];
      }
    }
    return nums.length;
  }
}
